import request from "@/utils/request";
import type {
    classInfoData,
    classListFormData,
    classResponseData,
    classAllResponseData,
    classListResponseData
} from "./type"

enum API {
    CLASS_ALL_URL = "/manage/class/all", //所有项
    CLASS_LIST_URL = "/manage/class/list",  //筛选项
    CLASS_ADD_URL = "/manage/class/add",  //添加项
    CLASS_GET_ID_URL = "/manage/class/find", //获取id
    CLASS_UPDATE_URL = "/manage/class/update", //修改
    CLASS_DELETE_URL = "/manage/class/delete" //删除
}
export const reqClassAll = () =>
    request.get<any, classAllResponseData>(API.CLASS_ALL_URL)
// 读筛选项
export const reqClassList = (data: classListFormData) =>
    request.post<any, classListResponseData>(API.CLASS_LIST_URL, data)
// 添加
export const reqClassAdd = (data: classInfoData) =>
    request.post<any, classResponseData>(API.CLASS_ADD_URL, data)

//ID获取
export const reqClassById = (_id: string) =>
    request.get<any, classResponseData>(API.CLASS_GET_ID_URL + `?_id=${_id}`)

// 修改
export const reqClassUpdata = (data: classInfoData) =>
    request.post<any, classResponseData>(API.CLASS_UPDATE_URL, data)
// 删除
export const reqClassDelete = (classId: string) =>
    request.post<any, classResponseData>(API.CLASS_DELETE_URL, { classId })